package student.stu23002101.chapter09;

import java.lang.reflect.Method;

class Person10 {
    private String name;
    private int age;
    public Person10(){}
    public Person10(String name){
        this.name = name;
    }
    public Person10(String name,int age){
        this.setName(name);
        this.setAge(age);
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public void sayHello(){
        System.out.println("Hello World!");
    }
    public String toString() {
        return "姓名："+this.name+",年龄："+this.age;
    }
}
public class Demo10_DCC {
    public static void main(String args[]){
        Class<?> c = null;
        try{
            c = Class.forName("teacher.chapter09.Person10");
        }catch(ClassNotFoundException e){
            e.printStackTrace();
        }
        try{
            Method met = c.getMethod("sayHello");
            met.invoke(c.newInstance());
        }catch(Exception e){
            e.printStackTrace();
        }
    }
}